package com.example.springapplicationdemo.handlerexceptionresolver;

import com.example.springapplicationdemo.handlerexceptionresolver.exception.NewsNotFoundException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("news_page_controller")
public class NewsPageController {

    @GetMapping("{id}/_update")
    public ModelAndView update(@PathVariable Long id){
        if (id.equals(1L)){
            throw new NewsNotFoundException(id);
        }
        return new ModelAndView("controller_success");
    }
}
